<template>
  <van-popup v-model:show="showBottom" round position="bottom" closeable>
    <div class="container">
      <h3>常见问题</h3>

      <div class="question">{{ faq.name }}</div>

      <div class="answer">{{ faq.content }}</div>

      <div class="confirm">
        <van-button type="primary" color="#ff1d41" @click="onConfirm"> 确认 </van-button>
      </div>
    </div>
  </van-popup>
</template>

<script setup>
import { ref, toRefs, watch } from 'vue'

const showBottom = ref(false)

const props = defineProps(['faq'])

const { faq } = toRefs(props)

watch(
  faq,
  (newFaq) => {
    if (newFaq) {
      showBottom.value = true
    }
  },
  {
    deep: true,
  },
)

const onConfirm = () => {
  showBottom.value = false
}
</script>

<style scoped lang="scss">
.container {
  padding: 10px;

  h3 {
    color: #333333;
    font-size: 18px;
    font-weight: 500;
    text-align: center;
    margin-top: 0;
  }

  .question {
    color: #333333;
    font-size: 17px;
    font-weight: 700;
    margin: 10px 0;
  }

  .answer {
    color: rgb(104, 103, 108);
    font-size: 12px;
    font-weight: 400;
    line-height: 24px;
    margin-bottom: 20px;
  }

  .confirm {
    background-color: #fff;
    padding: 5px 15px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;

    .van-button {
      width: 100%;
      height: 40px;
      font-size: 16px;
      font-weight: 600;
      border-radius: 22px;
    }
  }
}
</style>
